<?php

namespace app\modules\Finance\models;

use Yii;
use app\modules\Order\models\Order;

/**
 * This is the model class for table "finance_order".
 *
 * @property integer $id
 * @property integer $order_id
 * @property string $price
 */
class FinanceOrder extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'finance_order';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['order_id', 'finance_id', 'product_id'], 'integer'],
            [['order_code', 'product_code'], 'string', 'max' => 16],
            [['price'], 'number'],
        ];
    }



	//  获取对应订单信息
	public function getOrder(){
		
        return $this->hasOne(Order::className(), ['id' => 'order_id']);
	}

	// 获取对应的审批主信息
	public function getFinance(){
		
        return $this->hasOne(Finance::className(), ['id' => 'finance_id']);
	}

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => Yii::t('app', 'ID'),
            'order_id' => Yii::t('app', 'Order ID'),
            'product_id' => Yii::t('app', 'Product ID'),
            'price' => Yii::t('app', 'Price'),
        ];
    }
}
